{template 'common/header'}
<ul class="nav nav-tabs">
	<li {if $_GPC['op']=='display' || $_GPC['op']==''}class="active"{/if}><a href="{php echo $this->createWebUrl('merchant', array('op'=>'display'));}">商家列表</a></li>
	<li {if $_GPC['op']=='edit' && empty($id)}class="active"{/if}><a href="{php echo $this->createWebUrl('merchant', array('op'=>'edit'));}">添加商家</a></li>
	{if !empty($id)}
	<li class="active"><a href="{php echo $this->createWebUrl('merchant', array('op'=>'edit', 'id'=>$id));}">编辑商品</a></li>
	{/if}
</ul>
{if $_GPC['op']=='display' || $_GPC['op']==''}
	<div class="panel panel-default">
		<div class="panel-heading">商家列表</div>
		<div class="panel-body">
			<div class="table-responsive panel-body">
				<table class="table table-hover" style="min-width: 300px;">
					<thead class="navbar-inner">
						<tr>
							<th class="col-sm-1">商家ID</th>
							<th class="col-sm-2">商家名称</th>
							<th class="col-sm-1">商家行业</th>
							<th class="col-sm-1">商家logo</th>
							<th class="col-sm-2">联系人</th>
							<th class="col-sm-2">联系电话</th>
							<th class="col-sm-2">商家地址</th>
							<th class="col-sm-2 text-right">操作</th>
						</tr>
					</thead>
					<tbody>
						{loop $merchants $merchantid $merchant}
						<tr>
							<td>{$merchant['id']}</td>
							<td>{$merchant['name']}</td>
							<td>{$merchant['industry']}</td>
							<td><image src="{php echo tomedia($merchant['thumb']);}" style="max-width: 48px; max-height: 48px; border: 1px dotted gray"></td>
							<td>{$merchant['linkman_name']}</td>
							<td>{$merchant['linkman_mobile']}</td>
							<td>{$merchant['address']}</td>
							<td class="text-right">
								<a href="{php echo $this->createWebUrl('merchant', array('op'=>'edit', 'id'=>$merchant['id']));}" class="btn btn-default" data-toggle="tooltip" data-placement="top" title="" data-original-title="编辑"><i class="fa fa-pencil"></i></a>
								<a href="{php echo $this->createWebUrl('merchant',array('op'=>'delete','id'=>$merchant['id']));}" onclick="return confirm('此操作不可恢复，确认删除？');return false;" class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="删除"><i class="fa fa-times"></i>
								</a>
								<a href="{php echo $this->createWebUrl('mytoken', array('op' => 'display', 'merchantid' => $merchant['id']))}" class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="top" title="优惠卷详情"><i class="fa fa-cog fa-spin"></i></a>
							</td>
						</tr>
						{/loop}
						{if empty($merchants)}
						<tr>
							<td colspan="8">
								尚未添加商家
							</td>
						</tr>
						{/if}
					</tbody>
				</table>
				{$pager}
			</div>
		</div>
	</div>
{elseif $_GPC['op']=='edit'}
<div class="main">
	<form action="" method="post" class="form-horizontal form" id="form">
		<div class="panel panel-default">
			<div class="panel-heading">商家</div>
			<div class="panel-body">
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 col-lg-2 control-label">商家名称</label>
					<div class="col-xs-12 col-sm-8">
						<input type="text" name="merchant[name]" class="form-control" value="{$merchant['name']}" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 col-lg-2 control-label">商家logo</label>
					<div class="col-xs-12 col-sm-8">
						{php echo tpl_form_field_image('merchant[thumb]', $merchant['thumb']);}
						<span class="help-block">图片建议为200*150</span>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 col-lg-2 control-label">商家行业</label>
					<div class="col-xs-12 col-sm-8">
							<input type="text" name="merchant[industry]" class="form-control" value="{$merchant['industry']}">
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 col-lg-2 control-label">商家地址</label>
					<div class="col-xs-12 col-sm-8">
							<input type="text" name="merchant[address]" class="form-control" value="{$merchant['address']}">
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 col-lg-2 control-label">联系人</label>
					<div class="col-xs-12 col-sm-8">
							<input type="text" name="merchant[linkman_name]" class="form-control" value="{$merchant['linkman_name']}" >
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 col-lg-2 control-label">联系电话</label>
					<div class="col-xs-12 col-sm-8">
							<input type="text" name="merchant[linkman_mobile]" class="form-control" value="{$merchant['linkman_mobile']}" >
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 col-lg-2 control-label">商家详情</label>
					<div class="col-xs-12 col-sm-8">
						<textarea style="height:200px;" name="merchant[detail]" class="form-control richtext" cols="60">{$merchant['detail']}</textarea>
					</div>
				</div>
				{if !empty($id)}
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 col-lg-2 control-label">添加日期</label>
					<div class="col-xs-12 col-sm-8">
						<p class="form-control-static">{php echo date('Y-m-d', $merchant['createtime']);}</p>
					</div>
				</div>
				{/if}
				<div class="form-group">
					<div class="col-xs-12 col-sm-9 col-md-10 col-lg-10 col-sm-offset-3 col-md-offset-2 col-lg-offset-2">
						<input type="hidden" name="id" value="{$merchant['id']}" />
						<input name="submit" type="submit" value="提交" class="btn btn-primary" />
						<input type="hidden" name="token" value="{$_W['token']}" />
					</div>
				</div>
			</div>
		</div>
	</form>
</div>
{/if}
{template 'common/footer'}